﻿using GameFramework.Event;
using System;
using TowerDefence_Zombie.Data;

namespace TowerDefence_Zombie
{
    public class GuideCondition_AnyLevelFail : GuideCondition_Base
    {
        public GuideCondition_AnyLevelFail(DRGuideCondition conditionInfo, Action conitionCompleteClick)
            : base(conditionInfo, conitionCompleteClick)
        {

        }

        public override void StartCondition()
        {
            base.StartCondition();
            GameEntry.Event.Subscribe(LevelFailEventArgs.EventId, OnLevelFail);
        }

        private void OnLevelFail(object sender, GameEventArgs e)
        {
            LevelFailEventArgs ne = (LevelFailEventArgs)e;
            if (ne == null)
                return;

            IsCompleteFlag = true;
        }

        public override void Dispose()
        {
            GameEntry.Event.Unsubscribe(LevelFailEventArgs.EventId, OnLevelFail);
            base.Dispose();
        }
    }
}
